
public class RainGauge implements Comparable<RainGauge>{
	private String city;
	private String neighborhood;
	private int size;
	private int tipCount;
	private int currentRain;
	
	public RainGauge(String inCity, String inNeighborhood, int inSize) {
		city = inCity;
		neighborhood = inNeighborhood;
		size = inSize;
		
		tipCount = 0;
		currentRain = 0;
	}
	
	public String getCity() {
		return city;
	}
	
	public String getNeighborhood() {
		return neighborhood;
	}
	
	public int getTipCount() {
		return tipCount;
	}
	
	public void addRain(int additional) {
		if(additional < 0) {
			return;
		}
		
		int totalNew = currentRain + additional;
		int overflow = totalNew - size;
		if(overflow > 0) {
			tipCount++;
			currentRain = overflow;
			return;
		}
		
		currentRain += additional;
	}
	
	public int getTotalRain() {
		int total = (size * tipCount) + currentRain;
		return total;
	}
	
	public int compareTo(RainGauge other) {
		int myTotalRain = getTotalRain();
		int otherTotalRain = other.getTotalRain();
		
		if(myTotalRain != otherTotalRain) {
			return myTotalRain - otherTotalRain;
		}
		
		return city.compareTo(other.city);
	}
	
	public boolean equals(Object what) {
		RainGauge other = (RainGauge) what;
		
		if( ! city.equals(other.city)) {
			return false;
		}
		
		if( ! neighborhood.equals(other.neighborhood)) {
			return false;
		}
		
		return true;
	}
	
	public String toString() {
		String ret = "";
		
		ret += "city: " + city;
		ret += " neighborhood: " + neighborhood;
		ret += " size: " + size;
		ret += " tipcount: " + tipCount;
		
		return ret;
	}
}
